/**
* @file
* @author renzhiqiang
* @date 2017-04-13
*/
<template>
  <div>
    <form id='pay' action='https://secure.oceanpayment.com/gateway/service/pay' method='post'>
    </form>
  </div>
</template>
<script>
  import store from '../login-store';
  import {tools} from 'tools';
  import {FastClick} from 'fastclick';
  var $ = require('jquery');
  var lan = require('./../language.json');
  export default {
    components: {},
    data: function () {    // 组件的数据格式
      return {
        r: tools.getQueryString('r'),
        login: store.state,
        language: lan[window.lan]
      };
    },
    //  created 钩子在实例创建后,在reday之前调用
    created: function () {
      $('head title').html(this.language.EWallet);
    },
    route: {
      data: function (data) {
        tools.show(this.language.load);
        store.prepareEwalletPay(this.r, value => {
          setTimeout(function () {
            for (var obj in value) {
              $('#pay').append($('<input type="hidden"/>').attr('name', obj).attr('value', value[obj]));
            };
            $('#pay').submit();
          }, 1000);
        });
      }
    },
    ready: function () {
      mui('.mui-scroll-wrapper').scroll();
      FastClick.attach(document.body);
    }
  };
</script>
